package com.yili.oa.dao;

import com.yili.oa.models.Permission;
import com.yili.oa.models.PermissionExample;
import java.util.List;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.DeleteProvider;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.InsertProvider;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Result;
import org.apache.ibatis.annotations.Results;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.SelectProvider;
import org.apache.ibatis.annotations.Update;
import org.apache.ibatis.annotations.UpdateProvider;
import org.apache.ibatis.type.JdbcType;

public interface PermissionMapper {
    @SelectProvider(type=PermissionSqlProvider.class, method="countByExample")
    long countByExample(PermissionExample example);

    @DeleteProvider(type=PermissionSqlProvider.class, method="deleteByExample")
    int deleteByExample(PermissionExample example);

    @Delete({
        "delete from permission",
        "where permission_id = #{permissionId,jdbcType=VARCHAR}"
    })
    int deleteByPrimaryKey(String permissionId);

    @Insert({
        "insert into permission (permission_id, permission_name, ",
        "permission_key, permission_decription)",
        "values (#{permissionId,jdbcType=VARCHAR}, #{permissionName,jdbcType=VARCHAR}, ",
        "#{permissionKey,jdbcType=VARCHAR}, #{permissionDecription,jdbcType=VARCHAR})"
    })
    int insert(Permission record);

    @InsertProvider(type=PermissionSqlProvider.class, method="insertSelective")
    int insertSelective(Permission record);

    @SelectProvider(type=PermissionSqlProvider.class, method="selectByExample")
    @Results({
        @Result(column="permission_id", property="permissionId", jdbcType=JdbcType.VARCHAR, id=true),
        @Result(column="permission_name", property="permissionName", jdbcType=JdbcType.VARCHAR),
        @Result(column="permission_key", property="permissionKey", jdbcType=JdbcType.VARCHAR),
        @Result(column="permission_decription", property="permissionDecription", jdbcType=JdbcType.VARCHAR)
    })
    List<Permission> selectByExample(PermissionExample example);

    @Select({
        "select",
        "permission_id, permission_name, permission_key, permission_decription",
        "from permission",
        "where permission_id = #{permissionId,jdbcType=VARCHAR}"
    })
    @Results({
        @Result(column="permission_id", property="permissionId", jdbcType=JdbcType.VARCHAR, id=true),
        @Result(column="permission_name", property="permissionName", jdbcType=JdbcType.VARCHAR),
        @Result(column="permission_key", property="permissionKey", jdbcType=JdbcType.VARCHAR),
        @Result(column="permission_decription", property="permissionDecription", jdbcType=JdbcType.VARCHAR)
    })
    Permission selectByPrimaryKey(String permissionId);

    @UpdateProvider(type=PermissionSqlProvider.class, method="updateByExampleSelective")
    int updateByExampleSelective(@Param("record") Permission record, @Param("example") PermissionExample example);

    @UpdateProvider(type=PermissionSqlProvider.class, method="updateByExample")
    int updateByExample(@Param("record") Permission record, @Param("example") PermissionExample example);

    @UpdateProvider(type=PermissionSqlProvider.class, method="updateByPrimaryKeySelective")
    int updateByPrimaryKeySelective(Permission record);

    @Update({
        "update permission",
        "set permission_name = #{permissionName,jdbcType=VARCHAR},",
          "permission_key = #{permissionKey,jdbcType=VARCHAR},",
          "permission_decription = #{permissionDecription,jdbcType=VARCHAR}",
        "where permission_id = #{permissionId,jdbcType=VARCHAR}"
    })
    int updateByPrimaryKey(Permission record);
}